import 'package:flutter/material.dart';
import 'package:razer_one/app/main/constants/color_constants.dart';
import 'package:razer_one/app/main/extension/string_extension.dart';

sizeLine(double width, double height, {Color color = const Color(kLineColor)}) {
  return SizedBox(
    width: width,
    height: height,
    child: DecoratedBox(
      decoration: BoxDecoration(color: color),
    ),
  );
}

sizeH(double h) {
  return SizedBox(height: h);
}

Widget sizeW(double w) {
  return SizedBox(width: w);
}

class MainText extends StatelessWidget {
  final String title;
  final Color textColor;
  final double fontSize;
  final int maxLines;
  final Color? backgroundColor;
  final TextAlign textAlign;
  final FontWeight fontWeight;
  // final bool isSoftWrap;z
  const MainText(
    this.title, {
    Key? key,
    this.textColor = const Color(kBlack1FontColor),
    this.fontWeight = FontWeight.normal,
    this.fontSize = 15,
    this.maxLines = 1,
    this.backgroundColor,
    this.textAlign = TextAlign.start,
    // this.isSoftWrap = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Text(
      //字符不一样显示  title.replaceAll("", "\u200B"),如果有表情这个方法不适用,
      title.spaceWord,

      maxLines: maxLines,
      overflow: TextOverflow.ellipsis,
      textAlign: textAlign,
      // softWrap: maxLines > 1 ? true : isSoftWrap, //是否自动换行
      style: TextStyle(
        fontWeight: fontWeight,
        backgroundColor: backgroundColor,
        color: textColor,
        fontSize: fontSize,
      ),
    );
  }
}

class MainSideText extends StatelessWidget {
  final String title;
  final Color color;
  final double fontSize;
  const MainSideText(this.title,
      {Key? key,
      this.color = const Color(kLightGoldenColor),
      this.fontSize = 12})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      decoration: BoxDecoration(
          color: Colors.white,
          border: Border.all(
            width: 0.5, // 设置边框的宽度
            color: color, // 设置边框的颜色
          )),
      child: MainText(
        title,
        textColor: color,
        fontSize: fontSize,
      ),
    );
  }
}
